

/** vfork*/
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
int main(int argc,char ** argv)
{
	switch(vfork()){
		case -1:
			perror("fork error");
			return 1;
		case 0:
			printf("i am child process,pid:%d,getpgrp:%d,getsid:%d\n",getpid(),getpgrp(),getsid(0));
			setsid();
			printf("i am child process,pid:%d,getpgrp:%d,getsid:%d\n",getpid(),getpgrp(),getsid(0));
			_exit(0);
		default:
			printf("i am parent process,pid:%d,getpgrp:%d,getsid:%d\n",getpid(),getpgrp(),getsid(0));
			setsid();
			printf("i am parent process,pid:%d,getpgrp:%d,getsid:%d\n",getpid(),getpgrp(),getsid(0));
	}
	return 0;
}
